﻿namespace UnitBox {
	public class UnitBoxInterceptions {

		#region class fields

		private static bool _isLockedDown;

		#endregion


		#region public methods

		/// <summary>
		/// Locks down all future interceptions so that even if configured to do so, no further interception
		/// will take place. The intent of this is so to ensure that unintended interceptions cannot be
		/// performed during the production running of the code. Note that once called, the operation
		/// cannot be undone so long as the application is running.
		/// </summary>
		/// <remarks>
		/// This method should be called at the beginning of your production code. Test code should never
		/// call this method as it will prevent interceptions inside tests from occuring.
		/// </remarks>
		public static void Lockdown() {
			_isLockedDown = true;
		}

		#endregion


		#region properties

		internal static bool IsLockedDown {
			get { return _isLockedDown; }
		}

		#endregion


		#region public methods
		
		/// <summary>
		/// Resets any intereceptions that were set up by a test but perhaps not met.
		/// This allows tests to stay independent from one another, especially in scenarios where
		/// a test will fail and thus leave un-dequeued intereceptions lying around.
		/// </summary>
		///<remarks>
		/// You should call this at the end of every one of your tests (usually by putting in the the test
		/// cleanup/teardown of your test framework).
		/// </remarks>
		public static void ResetAllInterceptions() {
			SwapQueue.Reset();
			InterceptionQueue.Reset();
		}

		#endregion


		#region internal methods

#if DEBUG

		/// <summary>
		/// NOTE: This method is only used for testing so that tests can stay isolated from each other.
		/// This should NOT be compiled into the real delivered production code
		/// </summary>
		internal static void ResetLockdown() {
			_isLockedDown = false;
		}

#endif 

		#endregion

	}
}
